package com.jxb.demo.controller;

import com.jxb.demo.config.RedisLuaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

@RestController
@RequestMapping("/provider")
@RefreshScope
public class ServiceController {

    private static Logger logger = LoggerFactory.getLogger(ServiceController.class);

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Resource
    private RedisLuaService redisLuaService;

    @Value("${user.name}")
    private String userName;

    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String hello(){
        String result = "what spring boot is";
        logger.info("nacos username :{}",userName);
        redisLuaService.test();
        stringRedisTemplate.opsForValue().set("abc","jiaxuebing");
        return result;
    }


}
